//实验历史数据接口的管理
import $http from '@/service/request.js'

//功能：获取某设备所有实验记录列表信息
//接口：/historys/getall
//注意该接口返回的历史记录是某设备所有操作记录（包含所有用户），已经按照月份分组，用于实验记录列表的展示
//POST
export const _equipGetHistory = ({serialnum_equip}) =>{
	return $http.request({
		url:'/historys/getall',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			serialnum_equip
		}
	})
}

//功能：获取某设备单个用户的实验记录列表信息
//接口：/historys/get
//注意该接口返回的历史记录是单个用户对某一设备的简略操作记录，已经按照月份分组，用于实验记录列表的展示
//POST
export const _accountGetHistory = ({account_user,serialnum_equip}) =>{
	return $http.request({
		url:'/historys/get',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			account_user,
			serialnum_equip
		}
	})
}

//功能：根据实验记录序列号获取详细实验记录
//接口：/historys/getdetails
//注意该接口返回的历史记录是单个用户对某一设备的简略操作记录，已经按照月份分组，用于实验记录列表的展示
//POST
export const _serialnumGetHistory = ({serialnum_history}) =>{
	return $http.request({
		url:'/historys/getdetails',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			serialnum_history
		}
	})
}

//废弃
//功能：保存实验历史数据
//接口：/historys/save
//POST
export const _saveHistory = (data) =>{
	return $http.request({
		url:'/historys/save',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data
	})
}
// //功能：保存实验历史数据
// //接口：/historys/save
// //POST
// export const _saveHistory = ({account_user,name_exper,info_exper,serialnum_equip,runningtime_exper,rate_exper,historys}) =>{
// 	return $http.request({
// 		url:'/historys/save',
// 		method:'POST',
// 		header:{
// 			"Content-Type":"application/json"
// 		},
// 		data:{
// 			account_user,
// 			name_exper,
// 			info_exper,
// 			serialnum_equip,
// 			runningtime_exper,
// 			rate_exper,
// 			historys
// 		}
// 	})
// }

//功能：删除所有历史实验
//接口：/historys
//DELETE
export const _deleteHistory = ({serialnum_history}) =>{
	return $http.request({
		url:'/historys',
		method:'DELETE',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			serialnum_history
		}
	})
}

//功能：获取某用户所有实验记录列表信息
//接口：/historys
//POST
export const _allhistory = ({account_user}) =>{
	return $http.request({
		url:'/historys/getbyaccount',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			account_user
		}
	})
}

//功能：根据实验日期获取实验记录
//接口：/historys/getbydate
//POST
export const _gethistorybydate = ({account_user,date_history}) =>{
	return $http.request({
		url:'/historys/getbydate',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			account_user,
			date_history
		}
	})
}

//功能：根据实验名称获取实验记录
//接口：/historys/getbyname
//POST
export const _gethistorybyname = ({account_user,name_exper}) =>{
	return $http.request({
		url:'/historys/getbyname',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			account_user,
			name_exper
		}
	})
}


//功能：根据实验名称模糊搜索获取实验记录
//接口：/historys/getbyobscurename
//POST
export const _getbyobscurename = ({account_user,name_exper}) =>{
	return $http.request({
		url:'/historys/getbyobscurename',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			account_user,
			name_exper
		}
	})
}

//功能：将实验记录导出为excel表
//接口：/historys/export
//GET
export const _exportExcel = ({serialnum_history}) =>{
	return $http.request({
		url:'/historys/export',
		method:'GET',
		// header:{
		// 	"Content-Type":"application/json"
		// },
		data:{
			serialnum_history
		},
		responseType:'blob'
	})
}

//功能：查看设备实验表格
//接口：/historys/searchTime
//GET
export const _searchTime = ({serialnum_history}) =>{
	return $http.request({
		url:'/historys/searchTime',
		method:'GET',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			serialnum_history
		}
	})
}

//功能：查看设备实验表格
//接口：/historys/getbyserandacc
//POST
export const _searchequipExcel = ({account_user,serialnum_equip}) =>{
	return $http.request({
		url:'/historys/getbyserandacc',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			account_user,
			serialnum_equip
		}
	})
}

//功能：用户使用设备记录
//接口：/historys/equipUse
//GET
export const _diaryRecord = ({accountUser,serialnum,num}) =>{
	return $http.request({
		url:'/historys/equipUse',
		method:'GET',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			accountUser,
			serialnum,
			num
		}
	})
}